/**
 * 属性修饰符
 * 索引签名 (我们可以任意的给对象的属性定义类型，可以扩展对象的属性和范围)
 * */

interface StringArray {
  [index: number]: string
}

const myArray: StringArray = ['a', 'b']
const secondItem = myArray[0]

interface TestString {
  [prop: string]: number
}

let testString_index: TestString = {
  x: 100,
  y: 200,
  aaa: 300
}

interface Animal {
  name: string
}

interface Dog extends Animal {
  breed: string
}

interface notorOk {
  [index: string]: number | string,
  length: number,
  name: string
}

let notorok: notorOk = {
  x: 100,
  length: 100,
  name: 'felix'
}

interface ReadonlyStrArr {
  readonly [index: number]: string
}

let myArray2: ReadonlyStrArr = ['a', 'b']
// myArray2[0] = 'asd'